import Foundation
import Combine

@MainActor
final class AppEnvironment: ObservableObject {
    let destinationService: DestinationService
    let apiClient: APIClient
    let logger: LoggerType
    let userPreferences: UserPreferences
    let config: AppConfig

    init(
        destinationService: DestinationService = MockDestinationService(),
        apiClient: APIClient? = nil,
        logger: LoggerType = DefaultLogger(),
        userPreferences: UserPreferences = UserPreferences(),
        config: AppConfig = AppConfig.make()
    ) {
        self.config = config
        self.destinationService = destinationService
        self.apiClient = apiClient ?? APIClient(baseURL: config.baseURL)
        self.logger = logger
        self.userPreferences = userPreferences
    }

    convenience init(destinationService: DestinationService = MockDestinationService()) {
        self.init(
            destinationService: destinationService,
            apiClient: nil,
            logger: DefaultLogger(),
            userPreferences: UserPreferences(),
            config: AppConfig.make()
        )
    }
}


